<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class AddColumnAttrStrInStepReviewWorkflowRelationTable extends AbstractMigration
{
    public function up()
    {
        $this->table('step_review_workflow_relation')
            ->addColumn('project_template_id', 'integer', ['default' => 0, 'null' => false, 'limit' => 11, 'comment' => '工序流id'])
            ->addColumn('attr_str', 'string', ['default' => '', 'null' => false, 'limit' => 256, 'comment' => '属性attr'])
            ->addColumn('step_workflow_id', 'integer', ['default' => 0, 'null' => false, 'limit' => 11, 'comment' => '工序流id'])
            ->addIndex(['project_template_id', 'step_workflow_id', 'step_id', 'attr_str'], ['type' => 'unique', 'name' => 'idx_unique_step_workflow_attr'])
            ->save();

        $this->table('check_list')
            ->addColumn('review_role_config', 'string', ['default' => '', 'null' => false, 'limit' => 256, 'comment' => '审核节点的审核角色'])
            ->save();
    }

    public function down()
    {
        $this->table('step_review_workflow_relation')
            ->removeColumn('project_template_id')
            ->removeColumn('step_workflow_id')
            ->removeColumn('attr_str')
            ->removeIndexByName('idx_unique_step_workflow_attr')
            ->save();
        $this->table('check_list')
            ->removeColumn('review_role_config')
            ->save();
    }
}
